package cn.jhc.servlet;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.jhc.bean.HfmsgBean;

import cn.jhc.dao.ConnectionFactory;
import cn.jhc.dao.MsgDao;
@WebServlet(name="show one msg",urlPatterns={"/showonemsg.do"})
public class ShowOneMsgServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp)
    		throws ServletException, IOException {
    	req.setCharacterEncoding("UTF-8");
    	String id = req.getParameter("id");
		int Id = Integer.parseInt(id);
		HfmsgBean m = new HfmsgBean();
		MsgDao dao = new MsgDao();
		dao.setCon(ConnectionFactory.getConnection());
		m = dao.getoneMessages(Id);
		req.setAttribute("title", m);
    	RequestDispatcher dispatcher = req.getRequestDispatcher("/showmessages.jsp");
    	dispatcher.forward(req, resp);
    }
    protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		doGet(req, resp);
	}
}
